/**
 * *****************************************************************************
 * Dreampalace
 * ******************************************************************************
 *
 * Dreampalace is a special dreamdiary which helps dreamers to understand their
 * dreams. You can find also many features in Dreampalace to learn and hold the
 * lucid state in your dreams.
 *
 * *****************************************************************************
 *
 * Program	: Dreampalace Autor : PRo (Peter Rogge) Email : rogge-peter@gmx.de
 * Homepage : http://code.google.com/p/dreampalace License	: GNU General Public
 * License 3.0
 *
 *******************************************************************************
 *
 * This file is part of the project Dreampalace. Dreampalace is free software:
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation in version 3 of
 * the License only.
 *
 * Dreampalace is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * Dreampalace. If not, see <http://www.gnu.org/licenses/>.
 *
 * The Dreampalace project designates this particular file as subject to the
 * "Classpath" exception as provided by the Dreampalace project in the GPL
 * Version 3 section of the License file that accompanied this code.
 *
 *******************************************************************************
 */
package de.pro.dreampalace.file.links;

import com.zenjava.jfxflow.actvity.AbstractActivity;
import com.zenjava.jfxflow.navigation.Place;
import de.pro.dreampalace.file.api.EFileTyp;
import de.pro.dreampalace.file.links.api.ILinksManager;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.stage.WindowEvent;
import org.openide.util.Lookup;

/**
 *
 * @author Peter Rogge (PRo) <rogge-peter@gmx.de>
 */
public final class LinksEditorActivity extends AbstractActivity {

    @FXML
    private Label lbl = null;

    @Override
    protected final void activated() {
        System.out.println("LinksEditorActivity.activated()");

        /*
         * TODO - load links and categories from db
         */

        // XXX Test Contextmenu
        final ContextMenu contextMenu = new ContextMenu();
        contextMenu.setOnShowing(new EventHandler<WindowEvent>() {

            public void handle(WindowEvent e) {
                System.out.println("showing");
            }
        });
        contextMenu.setOnShown(new EventHandler<WindowEvent>() {

            public void handle(WindowEvent e) {
                System.out.println("shown");
            }
        });

        MenuItem item1 = new MenuItem("About");
        item1.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent e) {
                System.out.println("About");
            }
        });
        MenuItem item2 = new MenuItem("Preferences");
        item2.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent e) {
                System.out.println("Preferences");
            }
        });
        contextMenu.getItems().addAll(item1, item2);
        
        lbl.setContextMenu(contextMenu);
    }

    public final void onActionGoToPlaceLinks(final ActionEvent event) {
        System.out.println("onActionGoToPlaceLinks(ActionEvent)");

        final ILinksManager lm = Lookup.getDefault().lookup(ILinksManager.class);
        lm.getNavigationManager().goTo(new Place(EFileTyp.LINKS.getPlace()));
    }
}
